package com.example.product_practices.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.Objects;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "questionnaire")
public class Questionnaire {
    private static final long serialVersionUID = 1L;
    @TableId(type = IdType.AUTO)
    private Integer id;
    private String title;
    private String description;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
    private String style;

    private Integer userId;
    private Integer timesLimit;
    private Integer speAnswId;
    @TableLogic(value="1",delval="0")
    private Integer used;
    private Integer status;

    public Questionnaire(Questionnaire questionnaire) {
        if (Objects.nonNull(questionnaire)) {
            this.id = questionnaire.id;
            this.title = questionnaire.title;
            this.description = questionnaire.description;
            this.createTime = questionnaire.createTime;
            this.startTime = questionnaire.startTime;
            this.endTime = questionnaire.endTime;
            this.style = questionnaire.style;
            this.userId = questionnaire.userId;
            this.timesLimit = questionnaire.timesLimit;
            this.speAnswId = questionnaire.speAnswId;
            this.used = questionnaire.used;
            this.status = questionnaire.status;
        }
    }
}
